import 'hero.dart';

class HeroFactory {
  static Map<String, HeroFactory> factoryMap = {};
  static void addFactoryForType(HeroFactory factory, String type) {
    factoryMap[type] = factory;
  }

  static HeroFactory factoryForType(String type) {
    HeroFactory factory = factoryMap[type];
    return factory ?? HeroFactory();
  }

  static newHeroWithType(String type, Map map) {
    HeroFactory factory = HeroFactory.factoryForType(type);
    return factory.newHero(map);
  }

  Hero newHero(Map map) {
    return Hero(map);
  }
}